package semaphores;

import train.Train;

public class Vert implements State { 

	private static final Vert instance = new Vert();
	
	/**
	 * Private constructor prevents instantiation from other classes
	 */
	private Vert() {}
	
	/**
	 * 
	 * @return Return the unique instance of this class
	 */
	public final static Vert getInstance() {
	    return instance;
	}
    
    /**
     * Set the train's speed 
     * 
     * @param unTrain The train which see the semaphore sem
     */
    public void actionOnTrain(Train unTrain) {
		if(unTrain.getCurrentSpeed() == 0) {
    		//As the semaphore is green the train can run up to its maximal speed
    		unTrain.setCurrentSpeed(unTrain.getMaxSpeed());
		}
		//Else we don't modify the train's speed
    }
    
    public String toString() {
    	return "Je suis un feu vert";
    }
}